package com.itheima.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class Demo2Servlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int money=1000;
        PrintWriter writer=resp.getWriter();
        String path=req.getRequestURI();
        String type=path.substring(path.lastIndexOf("/"));
        if("/vip".equals(type)){
            writer.println(money*0.9);
        }
        else if("/vvip".equals(type)){
            writer.println(money*0.5);
        }
        else {
            writer.println(money);
        }
        writer.close();
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
/*
doget 与dopost的get与post获取，发送
声明，映射
/代表全部？/*呢
servletConfig的迭代器next原理
 */